Skip to content

Conversation

@Restart2008
Copy link

@Restart2008 Restart2008 commented Oct 26, 2025

…e Posts

Description:

Added a new hyperbolic formula for defensePostDefenseBuff with diminishing returns and upgradability for defense posts.

Variables
Y = total defense bonus (constant)
X = level of defense post (constant)
B = base constant of level 1 defense post (constant)
M = asymptote of the function
K = changes steepness of the curve

Formula: Y = B + M * ((X - 1) / (X - 1 + K))

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced

Please put your Discord username so you can be contacted if a bug or regression is found:

restart

@Restart2008 Restart2008 requested a review from a team as a code owner October 26, 2025 02:33
@CLAassistant
Copy link

CLAassistant commented Oct 26, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ryanbarlow97
❌ Restart2008
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

Warning

Rate limit exceeded

@ryanbarlow97 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3e03c28 and 7565546.

📒 Files selected for processing (2)
  • src/core/configuration/Config.ts (1 hunks)
  • src/core/configuration/DefaultConfig.ts (3 hunks)

Walkthrough

The Config API's defensePostDefenseBonus gains a required level parameter. DefaultConfig implements a level-based bonus formula and call sites now pass the defense post unit level. The DefensePost unit entry is marked upgradable: true.

Changes

Cohort / File(s) Summary
Config interface
src/core/configuration/Config.ts
Method signature changed to defensePostDefenseBonus(level: number): number (was parameterless).
DefaultConfig implementation & unit info
src/core/configuration/DefaultConfig.ts
defensePostDefenseBonus(level) now validates level >= 1 and computes a level-scaled bonus (replacing a fixed value); callers updated to pass dp.unit.level(); unitInfo.DefensePost now has upgradable: true.

Sequence Diagram(s)

sequenceDiagram
    participant Attacker as Attack logic
    participant Config as DefaultConfig
    participant Unit as DefensePost unit

    Attacker->>Unit: find defense post (dp)
    Note over Unit: dp.unit.level() → level
    Attacker->>Config: defensePostDefenseBonus(level)
    Config-->>Attacker: numeric bonus (level-scaled)
    Attacker->>Attacker: apply bonus in damage calculation
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify all call sites updated to pass level.
  • Inspect the level-scaling formula for correctness and edge-case handling (level < 1).
  • Confirm upgradable: true works with upgrade/construction logic.

Suggested labels

Balance Tweak, Feature - AI

A post that once gave five with ease,
Now grows with every level's breeze,
Callers pass the level in line,
Upgrades flagged and numbers climb. 🛡️

Pre-merge checks

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "feat: Implement hyperbolic defense bonus and upgradability for Defens…" directly corresponds to the main changes in the changeset. The code modifications update the defensePostDefenseBonus method signature to accept a level parameter and implement a hyperbolic formula with diminishing returns, while also adding upgradable: true to the DefensePost unit configuration. The title is specific enough for a teammate reviewing the repository history to understand that this PR introduces both a new calculation formula and the ability to upgrade defense posts.
Description Check ✅ Passed The pull request description clearly explains the changes being implemented, providing the mathematical formula (Y = B + M * ((X - 1) / (X - 1 + K))), defining all relevant variables, and explaining that the changes add a hyperbolic formula for defense bonuses with diminishing returns and upgradability for defense posts. This matches the code changes shown in the raw summary, where defensePostDefenseBonus now accepts a level parameter and implements the described calculation logic. The description is specific and directly related to the changeset content.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/core/configuration/DefaultConfig.ts (1)

310-312: Consider adding explanatory comments for the formula constants.

The magic numbers reduce readability. Add a brief comment explaining the hyperbolic curve behavior and why these specific values were chosen.

Example:

 defensePostDefenseBonus(level: number): number {
+  // Hyperbolic formula providing diminishing returns:
+  // Level 1: 5x defense, Level 2: ~8.3x, Level 3: 10x, Max (∞): 15x
   const baseValue = 5;
   const maxIncrease = 10;
   const k = 2;
   return baseValue + maxIncrease * ((level - 1) / (level - 1 + k));
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3478b3a and 668a995.

📒 Files selected for processing (2)
  • src/core/configuration/Config.ts (1 hunks)
  • src/core/configuration/DefaultConfig.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/core/configuration/Config.ts (2)
src/core/game/UnitImpl.ts (1)
  • level (406-408)
src/core/game/GameView.ts (1)
  • level (167-169)
src/core/configuration/DefaultConfig.ts (2)
src/core/game/UnitImpl.ts (1)
  • level (406-408)
src/core/game/GameView.ts (1)
  • level (167-169)
🔇 Additional comments (2)
src/core/configuration/DefaultConfig.ts (1)

672-673: LGTM!

The call site correctly passes the unit level to compute the dynamic defense bonus. The bonus is properly applied as a multiplier to the magnitude.

src/core/configuration/Config.ts (1)

154-154: All call sites verified and properly updated.

The signature change has been correctly implemented. The only call site in the codebase (DefaultConfig.ts:672) already passes the level parameter via dp.unit.level(), matching the new interface requirement.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 31, 2025
)) {
if (dp.unit.owner() === defender) {
mag *= this.defensePostDefenseBonus();
mag *= this.defensePostDefenseBonus(dp.unit.level());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this only checks if we have a stacked defense post, but we should also reduce speed if multiple defense posts are nearby

@github-actions
Copy link

This pull request is stale because it has been open for fourteen days with no activity. If you want to keep this pull request open, add a comment or update the branch.

@github-actions github-actions bot added the Stale PRs that haven't been touched for over two weeks. label Nov 20, 2025
@github-actions github-actions bot removed the Stale PRs that haven't been touched for over two weeks. label Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants